﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using LDTB.Common;
using LDTB.Common.Entities;

namespace LDTB.UI
{
    public partial class EditPeople : UIBase
    {

        int id = -1;
        public int PeopleID
        {
            get
            {
                if (Request["PeopleID"] != null)
                {
                    if (!int.TryParse(Request["PeopleID"].ToString(), out id))
                    {
                        id = -1;
                    }
                }
                return id;
            }
        }

        public VC_People _people = null;
        public VC_People People
        {

            get
            {
                if (_people == null && PeopleID != -1)
                {
                    var pl = (from p in Data.VC_Peoples
                              where p.ID == PeopleID
                              select p).FirstOrDefault();
                    if (pl != null)
                    {
                        _people = pl;
                    }
                }
                return _people;
            }
        }


        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                //Load huyen 
                LoadHuyen();
                LoadXa(null);
                if (PeopleID != -1)
                {
                    LoadPeople();
                }
            }


        }

        private void LoadXa(int? huyeid)
        {
            ddlXa.Items.Clear();
            ddlXa.Items.Add(new ListItem { Text = "----", Value = "-1" });

            IQueryable<ListItem> data = null;
            if (huyeid.HasValue)
            {

                data = (from d in Data.VC_Xas
                        where d.HuyenID == huyeid.Value
                        select new ListItem { Text = d.Name, Value = d.ID.ToString() });
            }
            else
            {
                if (People != null)
                {
                    data = (from d in Data.VC_Xas
                            select new ListItem { Selected = d.ID == People.XaID, Text = d.Name, Value = d.ID.ToString() });
                }
            }

            if (!DotNetNuke.Common.Utilities.Null.IsNull(data))
            {
                ddlXa.Items.AddRange(data.ToArray());
            }

            ddlXa.DataBind();

        }


        private void LoadHuyen()
        {
            ddlHuyen.Items.Clear();
            ddlHuyen.Items.Add(new ListItem { Text = "----", Value = "-1" });

            IQueryable<ListItem> data;
            if (People != null)
            {
                data = from d in Data.VC_Huyens
                       select new ListItem { Value = d.ID.ToString(), Text = d.Name, Selected = d.ID == People.VC_Xa.HuyenID };
            }
            else
            {
                data = from d in Data.VC_Huyens
                       select new ListItem { Value = d.ID.ToString(), Text = d.Name };
            }
            if (!DotNetNuke.Common.Utilities.Null.IsNull(data))
            {
                ddlHuyen.Items.AddRange(data.ToArray());
            }

            ddlHuyen.DataBind();
        }

        private void LoadPeople()
        {

            this.btnSaveAndContinue.Visible = false;
            this.btnSave.Text = "Lưu thay đổi";
            this.txtTenCoQuan.Text = People.TenCoQuan;
            for (int i = 0; i < ddlHuyen.Items.Count; i++)
            {
                if (ddlHuyen.Items[i].Value == People.VC_Xa.HuyenID.Value.ToString())
                {
                    ddlHuyen.SelectedIndex = i;
                }
            }

            for (int i = 0; i < ddlXa.Items.Count; i++)
            {
                if (ddlXa.Items[i].Value == People.XaID.Value.ToString())
                {
                    ddlXa.SelectedIndex = i;
                }
            }

            // I , gan gia tri
            VC_People pl = People;

            //thong tin nguoi
            txt_TT_FirstName.Text = pl.TT_FirstName;
            txt_TT_LastName.Text = pl.TT_Lastname;
            if (pl.TT_Sexual.Value) { dd_TT_Sex.SelectedIndex = 1; } else { dd_TT_Sex.SelectedIndex = 2; }
            txt_TT_NamSinh.Text = pl.TT_NamSinh.HasValue ? pl.TT_NamSinh.Value.ToString() : "";
            txt_TT_DienThoai.Text = pl.TT_DienThoai;
            txt_TT_Email.Text = pl.TT_Email;
            if (pl.TT_HonNhan.Value) { ddl_TT_HonNhan.SelectedIndex = 2; } else { ddl_TT_HonNhan.SelectedIndex = 1; };
            txt_TT_Dantoc.Text = pl.TT_DanToc;
            txt_TT_TrinhDoDatDuoc.Text = pl.TT_TrinhDoGiaoDuc;
            txt_TT_TrinhDoKyThuat.Text = pl.TT_TrinhDoChuyenMon;
            txt_TT_KyNangNgheNgiep.Text = pl.TT_ChuyenNganhDaoTao;

            //Thông tin việc làm
            if (pl.TTVL_KhoKhan.Value)
            {
                txt_TTVL_KhoKhan.Text = pl.TTVL_KhoKhanNoiDung;
                txt_TTVL_KhoKhan.ReadOnly = false;
                chk_TTVL_KhoKhan.Checked = true;
            }

            txt_TTVL_CapHanhChinh.Text = pl.TTVL_QLV_TCXH;
            txt_TTVL_CoQuanThuocNganh.Text = pl.TTVL_CQLV_HC;
            txt_TTVL_Thang.Text = pl.TTVL_ThoiGianLamViec.Value.Month.ToString();
            txt_TTVL_Nam.Text = pl.TTVL_ThoiGianLamViec.Value.Year.ToString();
            chk_TTVL_YeuNgheCTXH.Checked = pl.TTVL_YeuCTXH.Value;
            txt_TTVL_CongViecHienTai.Text = pl.TTVL_CongViecHienTai;
            txt_TTVL_CoQuanThuocNganh.Text = pl.TTVL_CoQuanThuocNganh;

            //Bồi dưỡng nghiệp vụ ngắn hạn
            if (pl.DTNH_BoiDuongCTXH.Value)
            {
                txt_DTNH_TapHuan.Text = pl.DTNH_BoiDuongCTXHNoiDung;
                txt_DTNH_TapHuan.ReadOnly = false;
                txt_DTNH_ThoiGianTapHuan.Text = pl.DTNH_ThoiGianTapHuan;
                txt_DTNH_ThoiGianTapHuan.ReadOnly = false;
            }
            chk_DTNH_TapHuan.Checked = pl.DTNH_BoiDuongCTXH.Value;

            //Đào tạo nâng cao Nghiệp vụ dài hạn
            if (pl.DTDH_DaoTaoChuyenMonCTXH.Value)
            {

                txt_DTDH_ChuyenMonNghiepVu.Text = pl.DTDH_DaoTaoChuyenMonCTXH_CMNV;
                txt_DTDH_ChuyenMonNghiepVu.ReadOnly = false;

                txt_DTDH_ChuyenMonNghiepVu_TrinhDo.Text = pl.DTDH_DaoTaoChuyenMonTrinhDo;
                txt_DTDH_ChuyenMonNghiepVu_TrinhDo.ReadOnly = false;
            }
            chk_DTDH_DaoTaoDaiHan.Checked = pl.DTDH_DaoTaoChuyenMonCTXH.Value;

            //Nhu cầu đào tạo ngắn hạn
            if (pl.NCDTNH_MongMuonDaoTaoNghiepVu.Value)
            {
                txt_NCDTNH_NhuCau.Text = pl.NCDTNH_MongMuonDaoTaoNghiepVu_NoiDung;
                txt_NCDTNH_NhuCau.ReadOnly = false;
                txt_NCDTNH_NhuCauThoiGian.Text = pl.NCDTNH_MongMuonDaoTaoNgiepVu_ThoiGian;
                txt_NCDTNH_NhuCauThoiGian.ReadOnly = false;
            }
            chk_NCDTNH_NhuCauDaoTaoNH.Checked = pl.NCDTNH_MongMuonDaoTaoNghiepVu.Value;

            //Nhu cầu đào tạo dài hạn
            if (pl.NCDTDH_NghiepVu.Value)
            {
                txt_NCDTDH_NhuCauDaoTaoDHTrinhDo.Text = pl.NCDTDH_TrinhDo;
                txt_NCDTDH_NhuCauDaoTaoDHTrinhDo.ReadOnly = false;

                txt_NCDTDH_NhuCauDaoTaoChuyeNganh.Text = pl.NCDTDH_ChuyenNganh;
                txt_NCDTDH_NhuCauDaoTaoChuyeNganh.ReadOnly = false;

                txt_NCDTDH_NhuCauDaoTaoDHHinhThuc.Text = pl.NCDTDH_HinhThuc;
                txt_NCDTDH_NhuCauDaoTaoDHHinhThuc.ReadOnly = false;
            }
            chk_NCDTDH_NhuCauDaoTaoDH.Checked = pl.NCDTDH_NghiepVu.Value;


            //Nhu cầu đạo tao bậc cao (Thạc sỹ,Tiến sỹ)
            if (pl.NCDTBC_NghiepVu.Value)
            {
                txt_NCDTBC_TrinhDo.Text = pl.NCDTBC_TrinhDo;
                txt_NCDTBC_TrinhDo.ReadOnly = false;

                txt_NCDTBC_TiengAnh.Text = pl.NCDTBC_TiengAnh;
                txt_NCDTBC_TiengAnh.ReadOnly = false;

                txt_NCDTBC_TrongNuoc.Text = pl.NCDTBC_DiaDiemTrongNuoc;
                txt_NCDTBC_TrongNuoc.ReadOnly = false;

                txt_NCDTBC_NuocNgoai.Text = pl.NCDTBC_DiaDiemNgoaiNuoc;
                txt_NCDTBC_NuocNgoai.ReadOnly = false;

                txt_NCDTBC_ODau.Text = pl.NCDTBC_DiaDiem;
                txt_NCDTBC_ODau.ReadOnly = false;

                txt_NCDTBC_ChuyenNganh.Text = pl.NCDTBC_ChuyenNganh;
                txt_NCDTBC_ChuyenNganh.ReadOnly = false;
            }

            chk_NCDTBC.Checked = pl.NCDTBC_NghiepVu.Value;
            //Kiến nghị,đề xuất


            string[] s = pl.KNDX_UTien.Split(','); // chkl_KNDX_CBYT.SelectedValue;
            for (int i = 0; i < s.Length; i++)
            {
                for (int j = 0; j < chkl_KNDX_CBYT.Items.Count; j++)
                {

                    if (s[i] == chkl_KNDX_CBYT.Items[j].Value)
                    {
                        chkl_KNDX_CBYT.Items[j].Selected = true;
                    }
                }
            }

            txt_KNDX.Text = pl.KNDX_NoiDung;
        }

        public bool SavePeopleToDataBase()
        {
            bool rt = false;

            if (ValidPeople())
            {
                //them moi

                VC_People pl;
                if (PeopleID == -1)
                {
                    pl = new VC_People();
                }
                else
                {
                    pl = (from p in Data.VC_Peoples
                          where p.ID == PeopleID
                          select p).FirstOrDefault();
                }
                //thong tin co quan huyen xa
                pl.TenCoQuan = txtTenCoQuan.Text.Trim();
                pl.XaID = int.Parse(ddlXa.SelectedValue);

                //thong tin nguoi
                pl.TT_FirstName = txt_TT_FirstName.Text.Trim();
                pl.TT_Lastname = txt_TT_LastName.Text.Trim();
                pl.TT_Sexual = dd_TT_Sex.SelectedValue == "0" ? false : true;
                pl.TT_NamSinh = int.Parse(txt_TT_NamSinh.Text.Trim());
                pl.TT_DienThoai = txt_TT_DienThoai.Text;
                pl.TT_Email = txt_TT_Email.Text.Trim();
                pl.TT_HonNhan = ddl_TT_HonNhan.SelectedValue == "1" ? false : true;
                pl.TT_DanToc = txt_TT_Dantoc.Text.Trim();
                pl.TT_TrinhDoGiaoDuc = txt_TT_TrinhDoDatDuoc.Text.Trim();
                pl.TT_TrinhDoChuyenMon = txt_TT_TrinhDoKyThuat.Text.Trim();
                pl.TT_ChuyenNganhDaoTao = txt_TT_KyNangNgheNgiep.Text.Trim();

                //Thông tin việc làm
                if (chk_TTVL_KhoKhan.Checked)
                {
                    pl.TTVL_KhoKhanNoiDung = txt_TTVL_KhoKhan.Text.Trim();
                }
                else
                {
                    pl.TTVL_KhoKhanNoiDung = "";
                }
                pl.TTVL_KhoKhan = chk_TTVL_KhoKhan.Checked;
                pl.TTVL_QLV_TCXH = txt_TTVL_CapHanhChinh.Text.Trim();
                pl.TTVL_CQLV_HC = txt_TTVL_CoQuanThuocNganh.Text.Trim();
                pl.TTVL_ThoiGianLamViec = DateTime.Parse(txt_TTVL_Thang.Text.Trim() + "/" + txt_TTVL_Nam.Text.Trim());
                pl.TTVL_YeuCTXH = chk_TTVL_YeuNgheCTXH.Checked;
                pl.TTVL_CongViecHienTai = txt_TTVL_CongViecHienTai.Text;
                pl.TTVL_CoQuanThuocNganh = txt_TTVL_CoQuanThuocNganh.Text;

                //Bồi dưỡng nghiệp vụ ngắn hạn
                if (chk_DTNH_TapHuan.Checked)
                {
                    pl.DTNH_BoiDuongCTXHNoiDung = txt_DTNH_TapHuan.Text.Trim();
                    pl.DTNH_ThoiGianTapHuan = txt_DTNH_ThoiGianTapHuan.Text;
                }
                else
                {
                    pl.DTNH_BoiDuongCTXHNoiDung = "";
                    pl.DTNH_ThoiGianTapHuan = null;
                }
                pl.DTNH_BoiDuongCTXH = chk_DTNH_TapHuan.Checked;

                //Đào tạo nâng cao Nghiệp vụ dài hạn
                if (chk_DTDH_DaoTaoDaiHan.Checked)
                {
                    pl.DTDH_DaoTaoChuyenMonCTXH_CMNV = txt_DTDH_ChuyenMonNghiepVu.Text.Trim();
                    pl.DTDH_DaoTaoChuyenMonTrinhDo = txt_DTDH_ChuyenMonNghiepVu_TrinhDo.Text.Trim();
                }
                else
                {
                    pl.DTDH_DaoTaoChuyenMonCTXH_CMNV = "";
                    pl.DTDH_DaoTaoChuyenMonTrinhDo = "";
                }
                pl.DTDH_DaoTaoChuyenMonCTXH = chk_DTDH_DaoTaoDaiHan.Checked;


                //Nhu cầu đào tạo ngắn hạn
                if (chk_NCDTNH_NhuCauDaoTaoNH.Checked)
                {
                    pl.NCDTNH_MongMuonDaoTaoNghiepVu_NoiDung = txt_NCDTNH_NhuCau.Text.Trim();
                    pl.NCDTNH_MongMuonDaoTaoNgiepVu_ThoiGian = txt_NCDTNH_NhuCauThoiGian.Text.Trim();
                }
                else
                {
                    pl.NCDTNH_MongMuonDaoTaoNghiepVu_NoiDung = "";
                    pl.NCDTNH_MongMuonDaoTaoNgiepVu_ThoiGian = null;
                }
                pl.NCDTNH_MongMuonDaoTaoNghiepVu = chk_NCDTNH_NhuCauDaoTaoNH.Checked;

                //Nhu cầu đào tạo dài hạn
                if (chk_NCDTDH_NhuCauDaoTaoDH.Checked)
                {
                    pl.NCDTDH_TrinhDo = txt_NCDTDH_NhuCauDaoTaoDHTrinhDo.Text.Trim();
                    pl.NCDTDH_ChuyenNganh = txt_NCDTDH_NhuCauDaoTaoChuyeNganh.Text.Trim();
                    pl.NCDTDH_HinhThuc = txt_NCDTDH_NhuCauDaoTaoDHHinhThuc.Text.Trim();
                }
                else
                {
                    pl.NCDTDH_TrinhDo = "";
                    pl.NCDTDH_ChuyenNganh = "";
                    pl.NCDTDH_HinhThuc = "";
                }
                pl.NCDTDH_NghiepVu = chk_NCDTDH_NhuCauDaoTaoDH.Checked;


                //Nhu cầu đạo tao bậc cao (Thạc sỹ,Tiến sỹ)
                if (chk_NCDTBC.Checked)
                {
                    pl.NCDTBC_TrinhDo = txt_NCDTBC_TrinhDo.Text.Trim();
                    pl.NCDTBC_TiengAnh = txt_NCDTBC_TiengAnh.Text.Trim();
                    pl.NCDTBC_DiaDiemTrongNuoc = txt_NCDTBC_TrongNuoc.Text.Trim();
                    pl.NCDTBC_DiaDiemNgoaiNuoc = txt_NCDTBC_NuocNgoai.Text.Trim();
                    pl.NCDTBC_DiaDiem = txt_NCDTBC_ODau.Text.Trim();
                    pl.NCDTBC_ChuyenNganh = txt_NCDTBC_ChuyenNganh.Text.Trim();
                }
                else
                {
                    pl.NCDTBC_TrinhDo = "";
                    pl.NCDTBC_TiengAnh = "";
                    pl.NCDTBC_DiaDiemTrongNuoc = "";
                    pl.NCDTBC_DiaDiemNgoaiNuoc = "";
                    pl.NCDTBC_DiaDiem = "";
                    pl.NCDTBC_ChuyenNganh = "";
                }
                pl.NCDTBC_NghiepVu = chk_NCDTBC.Checked;


                //Kiến nghị,đề xuất

                string vl = "";
                for (int i = 0; i < chkl_KNDX_CBYT.Items.Count; i++)
                {
                    if (chkl_KNDX_CBYT.Items[i].Selected)
                    {
                        vl += chkl_KNDX_CBYT.Items[i].Value + ",";
                    }
                }

                vl = vl.Replace("/,$/", "");

                pl.KNDX_UTien = vl;
                pl.KNDX_NoiDung = txt_KNDX.Text.Trim();

                if (PeopleID == -1) Data.VC_Peoples.InsertOnSubmit(pl);
                try
                {
                    Data.SubmitChanges();
                    rt = true;
                }
                catch (Exception e)
                {
                    rt = false;
                }

            }

            return rt;
        }

        protected void btnSave_Click(object sender, EventArgs e)
        {
            if(SavePeopleToDataBase())  Response.Redirect(DotNetNuke.Common.Globals.NavigateURL(TabId));
        }

        public bool ValidPeople()
        {
            bool valid = true;
            int x;
            string str_mss = "";
            DateTime st;

            //reset color
            ddlHuyen.Style.Add("background-color", "");
            ddlXa.Style.Add("background-color", "");
            dd_TT_Sex.Style.Add("background-color", "");
            txt_TT_NamSinh.Style.Add("background-color", "");
            ddl_TT_HonNhan.Style.Add("background-color", "");
            txt_TTVL_Thang.Style.Add("background-color", "");
            txt_TTVL_Nam.Style.Add("background-color", "");
            txt_DTNH_ThoiGianTapHuan.Style.Add("background-color", "");
            txt_NCDTNH_NhuCauThoiGian.Style.Add("background-color", "");

            if (ddlHuyen.SelectedValue == "-1")
            {
                valid = false;
                ddlHuyen.Style.Add("background-color", "red");
                str_mss = "Chọn huyện ";
            }
            else if (ddlXa.SelectedValue == "-1")
            {
                valid = false;
                ddlXa.Style.Add("background-color", "red");
                str_mss = "Chọn xã";
            }
            else if (dd_TT_Sex.SelectedValue == "-1")
            {
                valid = false;
                dd_TT_Sex.Style.Add("background-color", "red");
                str_mss = "Chọn giới tính";
            }
            else if (!int.TryParse(txt_TT_NamSinh.Text.Trim(), out x))
            {
                valid = false;
                txt_TT_NamSinh.Style.Add("background-color", "red");
                str_mss = "Điền năm sinh";
            }
            else if (ddl_TT_HonNhan.SelectedValue == "-1")
            {
                valid = false;
                ddl_TT_HonNhan.Style.Add("background-color", "red");
                str_mss = "Điền tình trạng hôn nhân ";

            }
            else if (!int.TryParse(txt_TTVL_Thang.Text.Trim(), out x))
            {
                valid = false;
                txt_TTVL_Thang.Style.Add("background-color", "red");
                str_mss = "Điền tháng ";

            }
            else if (!int.TryParse(txt_TTVL_Nam.Text.Trim(), out x))
            {
                valid = false;
                txt_TTVL_Nam.Style.Add("background-color", "red");
                str_mss = "Điền năm ";

            }
            else if (!DateTime.TryParse(txt_TTVL_Thang.Text.Trim() + "/" + txt_TTVL_Nam.Text.Trim(), out st))
            {

                valid = false;
                txt_TTVL_Nam.Style.Add("background-color", "red");
                txt_TTVL_Thang.Style.Add("background-color", "red");
                str_mss = "Năm tháng không hợp lệ";

            }
            //else if (chk_DTNH_TapHuan.Checked && !int.TryParse(txt_DTNH_ThoiGianTapHuan.Text.Trim(), out x))
            //{
            //    valid = false;
            //    txt_DTNH_ThoiGianTapHuan.Style.Add("background-color", "red");
            //    str_mss = "Thời gian tập huấn ";

            //}
            //else if (chk_NCDTNH_NhuCauDaoTaoNH.Checked && !int.TryParse(txt_NCDTNH_NhuCauThoiGian.Text.Trim(), out x))
            //{
            //    valid = false;
            //    txt_NCDTNH_NhuCauThoiGian.Style.Add("background-color", "red");
            //    str_mss = "Nhu cầu đào tạo ";
            //}
            pl_mss.InnerText = str_mss;
            return valid;
        }

        protected void ddlHuyen_SelectedIndexChanged(object sender, EventArgs e)
        {
            int huyenid = int.Parse(ddlHuyen.SelectedValue);
            LoadXa(huyenid);
        }

        protected void Change_TTVL_KhoKhan(object sender, EventArgs e)
        {
            if (chk_TTVL_KhoKhan.Checked)
            {
                txt_TTVL_KhoKhan.ReadOnly = false;

            }
            else
            {
                txt_TTVL_KhoKhan.ReadOnly = true;

            }
        }

        protected void Change_DTNH_TapHuan(object sender, EventArgs e)
        {

            if (chk_DTNH_TapHuan.Checked)
            {
                txt_DTNH_TapHuan.ReadOnly = false;
                txt_DTNH_ThoiGianTapHuan.ReadOnly = false;
            }
            else
            {
                txt_DTNH_TapHuan.ReadOnly = true;
                txt_DTNH_ThoiGianTapHuan.ReadOnly = true;
            }
        }

        protected void Change_DTDH_DaoTaoDaiHan(object sender, EventArgs e)
        {
            if (chk_DTDH_DaoTaoDaiHan.Checked)
            {
                txt_DTDH_ChuyenMonNghiepVu.ReadOnly = false;
                txt_DTDH_ChuyenMonNghiepVu_TrinhDo.ReadOnly = false;
            }
            else
            {
                txt_DTDH_ChuyenMonNghiepVu.ReadOnly = true;
                txt_DTDH_ChuyenMonNghiepVu_TrinhDo.ReadOnly = true;
            }
        }

        protected void Change_NCDTNH_NhuCauDaoTao(object sender, EventArgs e)
        {
            if (chk_NCDTNH_NhuCauDaoTaoNH.Checked)
            {
                txt_NCDTNH_NhuCau.ReadOnly = false;
                txt_NCDTNH_NhuCauThoiGian.ReadOnly = false;
            }
            else
            {
                txt_NCDTNH_NhuCau.ReadOnly = true;
                txt_NCDTNH_NhuCauThoiGian.ReadOnly = true;
            }
        }
        protected void Change_NCDTDH_NhuCauDaoTaoDaiHan(object sender, EventArgs e)
        {
            if (chk_NCDTDH_NhuCauDaoTaoDH.Checked)
            {
                txt_NCDTDH_NhuCauDaoTaoChuyeNganh.ReadOnly = false;
                txt_NCDTDH_NhuCauDaoTaoDHHinhThuc.ReadOnly = false;
                txt_NCDTDH_NhuCauDaoTaoDHTrinhDo.ReadOnly = false;
            }
            else
            {

                txt_NCDTDH_NhuCauDaoTaoChuyeNganh.ReadOnly = true;
                txt_NCDTDH_NhuCauDaoTaoDHHinhThuc.ReadOnly = true;
                txt_NCDTDH_NhuCauDaoTaoDHTrinhDo.ReadOnly = true;
            }
        }

        protected void Change_NCDTBC(object sender, EventArgs e)
        {
            if (chk_NCDTBC.Checked)
            {
                txt_NCDTBC_ChuyenNganh.ReadOnly = false;
                txt_NCDTBC_NuocNgoai.ReadOnly = false;
                txt_NCDTBC_ODau.ReadOnly = false;
                txt_NCDTBC_TiengAnh.ReadOnly = false;
                txt_NCDTBC_TrinhDo.ReadOnly = false;
                txt_NCDTBC_TrongNuoc.ReadOnly = false;
            }
            else
            {
                txt_NCDTBC_ChuyenNganh.ReadOnly = true;
                txt_NCDTBC_NuocNgoai.ReadOnly = true;
                txt_NCDTBC_ODau.ReadOnly = true;
                txt_NCDTBC_TiengAnh.ReadOnly = true;
                txt_NCDTBC_TrinhDo.ReadOnly = true;
                txt_NCDTBC_TrongNuoc.ReadOnly = true;
            }
        }

        protected void btnCancel_Click(object sender, EventArgs e)
        {
            Response.Redirect(DotNetNuke.Common.Globals.NavigateURL());
        }

        protected void btnSaveAndContinue_Click(object sender, EventArgs e)
        {
            if (SavePeopleToDataBase())
            {
                pl_mss.InnerText = "Thêm mới thành công";
                pl_mss.Style.Add("color", "blue");
            }
        }
    }
}